/*
 * GuiFactory.java - ScriptME
 * 
 * Copyright (c) 2009 Cesar Henriques <cesar at alttab.com.ar>.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the GNU Lesser Public License v2.1
 * which accompanies this distribution, and is available at
 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
 * 
 * Based on FESI Project
 * 
 * Contributors:
 * 	Jean-Marc Lugrin - initial API and implementation
 * 	Cesar Henriques <cesar at alttab.com.ar> - J2ME Porting and Extensions
 */
package org.scriptme.ecmascript.gui;

import javax.microedition.midlet.MIDlet;

/**
 * Factory class to create the GUI elements, used to achieve independence of GUI
 * implementation at compile time.
 */
public abstract class GuiFactory {

	/** The _this. */
	private static GuiFactory _this;

	/**
	 * Gets the single instance of GuiFactory.
	 * 
	 * @return single instance of GuiFactory
	 */
	public static GuiFactory getInstance() {
		if (_this == null) {
			// TODO: detect platform to build a native Implementation
			_this = new GuiFactoryImpl();
		}
		return _this;
	}

	/**
	 * Display a message box (using the GUI of the console) with specified title
	 * and text.
	 * 
	 * @param title
	 *            the title
	 * @param msg
	 *            the msg
	 * 
	 * @return the message box
	 */
	public abstract MessageBox displayMessageBox(String title, String msg);

	/**
	 * Create aa new console.
	 * 
	 * @param itrpParam
	 *            the itrp param
	 * @param title
	 *            the title
	 * @param rows
	 *            the rows
	 * @param columns
	 *            the columns
	 * 
	 * @return the console
	 */
	public abstract Console makeConsole(InterpreterCommands itrpParam,
			String title, int rows, int columns);

	/**
	 * Create PromptBox.
	 * 
	 * @param title
	 *            the title
	 * @param prompt
	 *            the prompt
	 * @param defaultResponse
	 *            the default response
	 * 
	 * @return the prompt box
	 */
	public abstract PromptBox prompt(String title, String prompt,
			String defaultResponse);

	/**
	 * Create ConfirmationBox.
	 * 
	 * @param title
	 *            the title
	 * @param msg
	 *            the msg
	 * 
	 * @return the confirmation box
	 */
	public abstract ConfirmationBox confirm(String title, String msg);

	/**
	 * Set current midlet.
	 * 
	 * @param _midlet
	 *            the _midlet
	 */
	public abstract void setMidlet(MIDlet _midlet);
}
